# -*-coding:utf-8-*-
"""
@project: SM
@Time: 2024-08-01 19:55
@Author: Loneliness_Burial
@File: admin_interface.py
@Motto: 深情不改必坠死海
@software: pycharm
@version: python 3.7
"""

from db import db_handler
from lib import common

"""
管理员相关的接口
"""

logger = common.get_logger('admin')


def lock_admin_interface(username):
    user_data = db_handler.select_data(username)
    if not user_data:
        return False, f'\n用户: {username} 不存在! '
    if user_data.get('locked'):
        user_data['locked'] = False
        db_handler.save(user_data)
        msg = f'用户: {username} 已解冻! '
        logger.info(msg)
        return True, msg
    user_data['locked'] = True
    db_handler.save(user_data)
    msg = f'用户: {username} 已冻结！'
    logger.warning(msg)
    return True, msg
